package com.fay.effectivech4;

import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.Set;

/**
 * @Title:
 * @Description:
 * @Author Fay Wang
 * @Date 2022/2/21 15:14
 * @Version 1.0
 */
public class InstrumentedSet <E> extends ForwardingSet<E>{
    private int addCount = 0;

    public InstrumentedSet(Set<E> s) {
        super(s);
    }

    @Override
    public boolean add(E e) {
        addCount++;
        return super.add(e);
    }

    @Override
    public boolean addAll(@NotNull Collection<? extends E> c) {
        addCount += c.size();
        return super.addAll(c);
    }

    public int getAddCount() {
        return addCount;
    }
}
